package com.park.controller;

import com.park.bean.Attracts;
import com.park.common.CommonResult;
import com.park.dao.IChartDao;
import com.park.service.IChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;

@RestController
@CrossOrigin
public class ChartController {
    @Autowired
    IChartService chartService;

    @GetMapping("chart/tickets")
    public CommonResult getPriceOfTicketsPerDay(){
        List<BigDecimal> list=chartService.getPriceOfTicketsPerDat();
        Collections.reverse(list);
        return CommonResult.success(list);
    }
    @GetMapping("chart/week")
    public CommonResult getWeek(){
        List<LocalDate> list=chartService.getWeek();
        Collections.reverse(list);
        return CommonResult.success(list);
    }
    @GetMapping("chart/attracts")
    public CommonResult chartAttracts(){
        List<Attracts> list=chartService.chartAttracts();
        return CommonResult.success(list);
    }
}
